﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageReview.aspx.cs" Inherits="AffiliateClick.Admin.ManageReview" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Manage Page Content</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" />
    <div>
        <table>
            <tr>
                <td valign="top">
                    <asp:GridView ID="gv_Reviews" runat="server" DataSourceID="SqlDS_Reviews" AutoGenerateColumns="False"
                        DataKeyNames="ID" SelectedIndex="0" AutoGenerateDeleteButton="true"
                        AutoGenerateSelectButton="true" OnRowDeleted="gv_Reviews_RowDeleted"  Width="100%">
                        <EmptyDataTemplate>
                            No Data Found.
                            <asp:Button ID="btnInsert" runat="server" Text="Insert One" OnClick="Detail_Insert" />
                        </EmptyDataTemplate>
                        <Columns>
                            <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ItemStyle-Width="50px"
                                InsertVisible="False" ReadOnly="True" />
                            <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID"
                                ItemStyle-Width="50px" />
                            <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName"
                                ItemStyle-Width="50px" />
                            <asp:BoundField DataField="CategoryTitle" HeaderText="CategoryTitle" SortExpression="CategoryTitle" />
                            <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
                            <asp:BoundField DataField="rate" HeaderText="rate" SortExpression="rate" />
                        </Columns>
                    </asp:GridView>
                    <p>
                        <asp:DetailsView AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="Details"
                            HeaderText="Page Content Details" ID="dv_PageContent" runat="server"
                            OnItemUpdated="dv_PageContent_ItemUpdated" Width="100%">
                            <Fields>
                                <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" InsertVisible="false"
                                    SortExpression="ID" />
                                <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
                                <asp:TemplateField HeaderText="Language" SortExpression="LanguageKey">
                                    <EditItemTemplate>
                                        <asp:DropDownList runat="server" ID="ddl_Language" SelectedValue='<%# DataBinder.Eval(Container.DataItem,"Language").Equals("zh-CN")?"zh-CN" : "en-US" %>'>
                                            <asp:ListItem Text="<%$ Resources:GlobalResource,Chinese%>" Value="zh-CN" />
                                            <asp:ListItem Text="<%$ Resources:GlobalResource,English%>" Value="en-US" />
                                        </asp:DropDownList>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Language") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Title" SortExpression="Title">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtBoxText" runat="server" Text='<%# Bind("Title") %>' Columns="50"></asp:TextBox>
                                        <br />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator_Text" runat="server" ControlToValidate="txtBoxText"
                                            Display="Dynamic" ErrorMessage="Input Required" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator_Text" runat="server"
                                            ControlToValidate="txtBoxText" Display="Dynamic" ErrorMessage="Max 50 Chars"
                                            ValidationExpression=".{1,50}" ValidationGroup="Detail"></asp:RegularExpressionValidator>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Description" SortExpression="Description">
                                    <EditItemTemplate>
                                        <htmlEditor:HtmlEditor ID="txtBoxComment" runat="server" Text='<%# Bind("Review") %>' />
                                        <br />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator_Comment" runat="server" ControlToValidate="txtBoxComment"
                                            Display="Dynamic" ErrorMessage="Input Required" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("Review") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:CommandField ShowEditButton="True" ValidationGroup="Detail" />
                            </Fields>
                        </asp:DetailsView>
                        <asp:SqlDataSource ID="Details" runat="server" ConnectionString="<%$ ConnectionStrings:AC_DBConnectionString %>"
                            SelectCommand="SELECT * FROM [AC_Reviews] WHERE ([ID] = @ID)" UpdateCommand="UPDATE [AC_Reviews] SET [CategoryID] = @CategoryID, [Language] = @LanguageKey, [Title] = @Title, [Review] = @Review WHERE [ID] = @ID">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="gv_Reviews" Name="ID" PropertyName="SelectedValue"
                                    Type="String" />
                            </SelectParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="CategoryID" Type="String" />
                                <asp:ControlParameter ControlID="dv_PageContent$ddl_Language" Name="LanguageKey"
                                    Type="String" PropertyName="SelectedValue" />
                                <asp:Parameter Name="Title" Type="String" />
                                <asp:Parameter Name="Review" Type="String" />
                                <asp:Parameter Name="ID" Type="Int32" />
                            </UpdateParameters>
                        </asp:SqlDataSource>
                    </p>
                </td>
            </tr>
        </table>
    </div>
    <asp:SqlDataSource ID="SqlDS_Reviews" runat="server" ConnectionString="<%$ ConnectionStrings:AC_DBConnectionString %>"
        SelectCommand="AC_GetAllReviews" DeleteCommand="DELETE FROM [AC_Reviews] WHERE [ID] = @ID"
        SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ProfileParameter DefaultValue="en-US" Name="Language" PropertyName="PreferredCulture"
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
